package com.xyyl.patient.service.user;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xyyl.patient.core.constant.AppEnum;
import com.xyyl.patient.entity.user.PatientDiagnostic;
import com.xyyl.patient.mapper.user.PatientDiagnosticMapper;

 /**
 * @projectName:xyyl-oms-server
 * @ClassName: PatientDiagnostic
 * @Description:PatientDiagnostic
 * @author @author wqs
 * @date 2018-04-03 10:00:51
 */
@Service("patientDiagnosticService")
public class PatientDiagnosticServiceImpl implements PatientDiagnosticService {

	@Autowired
	private PatientDiagnosticMapper patientDiagnosticMapper;

	@Override
	public int insert(PatientDiagnostic patientDiagnostic) {
		// 插入创建既往病史时间
		patientDiagnostic.setCreateTime(new Date());
		patientDiagnosticMapper.insert(patientDiagnostic);
		return patientDiagnostic.getId();
	}

	@Override
	public int delete(Integer pdId) {
		PatientDiagnostic patientDiagnostic = patientDiagnosticMapper.selectOne(pdId);
		int result = 0;
		if (null != patientDiagnostic) {
			//删除状态变为1
			patientDiagnostic.setStatus(AppEnum.common.patientdiagnostic__type_delete.getValue());
			return patientDiagnosticMapper.update(patientDiagnostic);
		} else {
			return result;
		}
	}

	@Override
	public int update(PatientDiagnostic patientDiagnostic) {
		// 修改既往病史时间
		patientDiagnostic.setUpdateTime(new Date());
		return patientDiagnosticMapper.update(patientDiagnostic);

	}

	@Override
	public List<PatientDiagnostic> queryList(Integer archivesId) {
		return patientDiagnosticMapper.queryList(archivesId);
	}

	@Override
	public PatientDiagnostic queryById(Integer pdId) {

		return patientDiagnosticMapper.selectOne(pdId);
	}
	
}
